<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/ajax.js"></script>
</head>

<body>
    <script>
        /* 
           测试Ajax GET方法的测试
       */
        // ajax({
        //     type: 'GET',
        //     url: 'http://120.78.190.136:8080/spboot/encapsulationAjaxToolsGet?args=aaa',
        //     success: function(data,request) {
        //         console.log("请求成功");
        //         console.log(data);
        //     },
        //     error: function(data,request) {
        //         console.log("请求失败");
        //         console.log(data);
        //         console.log(request);
        //     }
        // });

        /* 
            测试Ajax POST方法的测试
        */
        // ajax({
        //     type: 'POST',
        //     url: 'http://120.78.190.136:8080/spboot/encapsulationAjaxToolsPost',
        //     data: {
        //         args: 'aabbb',
        //     },
        //     success: function(data,request) {
        //         console.log("post 请求成功");
        //         console.log(data);
        //     },
        //     error: function(data,request) {
        //         console.log("post 请求失败");
        //         console.log(data);
        //         console.log(request);
        //     }
        // });
        /* 
            测试请求参数为JSON格式
        */
        ajax({
            type: 'POST',
            url: 'http://120.78.190.136:8080/spboot/encapsulationAjaxToolsPostParamsJson',
            data: {
                username: 'zhangsan',
                password: '123',
                gender: 'female',
                age: 22
            },
            header: {
                'Content-Type': 'application/json'
            },
            success: function (data, request) {
                console.log("json request format 请求成功");
                console.log(data);
            },
            error: function (data, request) {
                console.log("json request format 请求失败");
                console.log(data);
                console.log(request);
            }
        });

    </script>
</body>

</html>